import torchvision
from torchvision import transforms
from torch.utils.data import DataLoader

def get_data_loaders(batch_size=128, num_workers=0, data_dir='E:/代码仓库/测试数据集'):
    # 定义转换，包括调整大小和归一化
    transform = transforms.Compose([
        transforms.Resize((32, 32)),
        transforms.ToTensor()
    ])

    train_dataset = torchvision.datasets.CIFAR10(root=data_dir, train=True,
                                                 transform=transform, download=True)
    test_dataset = torchvision.datasets.CIFAR10(root=data_dir, train=False,
                                                transform=transform, download=True)

    train_loader = DataLoader(dataset=train_dataset,
                              batch_size=batch_size,
                              shuffle=True,
                              num_workers=num_workers)

    test_loader = DataLoader(dataset=test_dataset,
                             batch_size=batch_size,
                             shuffle=False,
                             num_workers=num_workers)

    return train_loader, test_loader